import Vue from 'vue'
import Router from 'vue-router'

import register from '../components/register.vue'
import login from '../components/login.vue'
import retrieve from '../components/retrieve.vue'
import articleList from '../components/articleList.vue'
import search from '../components/search.vue'
import articleDetail from '../components/articleDetail.vue'
import my_account from '../components/my_account.vue'
import othercommentList from '../components/othercommentList.vue'
import userSetting from '../components/userSetting.vue'
import changePwd from '../components/changePwd.vue'
import mymessage from '../components/mymessage.vue'

Vue.use(Router)

export default new Router({
  routes: [
    // 重定向设为注册页
    {
      path: '/',
      name: 'register',
      redirect:'register'
    },
    {
      path: '/my_account',
      redirect:'mymessage'
    },
    {
      path:'/register',// 注册的路径，当路由匹配上/register，会渲染component中的组件
      name:'register',// register路由名字
      component:register //register路由对应的组件
    },
    {
      path:'/login',
      name:'login',
      component:login
    },
    {
      path:'/retrieve',
      name:'retrieve',
      component:retrieve
    },
    {
      path:'/articleList',
      name:'articleList',
      component:articleList
    },
    {
      path:'/search',
      name:'search',
      component:search
    },
    {
      path:'/articleDetail',
      name:'articleDetail',
      component:articleDetail
    },
    {
      path:'/my_account',
      name:'my_account',
      component:my_account,
      children:[
        {path:'/othercommentList',component:othercommentList},
        {path:'/mymessage',component:mymessage}
      ]
    },
    {
      path:'/userSetting',
      name:'userSetting',
      component:userSetting
    },
    {
      path:'/changePwd',
      name:'changePwd',
      component:changePwd
    }
  ],
  mode:'history'
})
